package com.huhao.wshare.Dynamic;

import java.util.List;

public class DynamicItem {
    private final int id;
    private final Author author;
    private final String textContent;
    private final List<String> imageUrls;
    private final String video;
    private final String createTime;
    private final List<Author> likers;
    private final List<Comment> comments;
    private final boolean likedByCurrentUser;

    public DynamicItem(int id, Author author, String textContent, List<String> imageUrls, String video, String createTime, List<Author> likers, List<Comment> comments, boolean likedByCurrentUser) {
        this.id = id;
        this.author = author;
        this.textContent = textContent;
        this.imageUrls = imageUrls;
        this.video = video;
        this.createTime = createTime;
        this.likers = likers;
        this.comments = comments;
        this.likedByCurrentUser = likedByCurrentUser;
    }

    public int getId() {
        return id;
    }

    public Author getAuthor() {
        return author;
    }

    public String getTextContent() {
        return textContent;
    }

    public List<String> getImageUrls() {
        return imageUrls;
    }

    public String getVideo() {
        return video;
    }

    public String getCreateTime() {
        return createTime;
    }

    public List<Author> getLikers() {
        return likers;
    }

    public List<Comment> getComments() {
        return comments;
    }

    public boolean isLikedByCurrentUser() {
        return likedByCurrentUser;
    }

    public DynamicItem updateLikeStatus(boolean likedByCurrentUser, List<Author> likers) {
        return new DynamicItem(
                this.id,
                this.author,
                this.textContent,
                this.imageUrls,
                this.video,
                this.createTime,
                likers,
                this.comments,
                likedByCurrentUser
        );
    }

    public DynamicItem updateComments(List<Comment> newComments) {
        return new DynamicItem(
                this.id,
                this.author,
                this.textContent,
                this.imageUrls,
                this.video,
                this.createTime,
                this.likers,
                newComments,
                this.likedByCurrentUser
        );
    }
}